﻿using System;

namespace RuoVea.ExUtil.Exceptions
{

    /// <summary>
    /// 描 述：链接错误
    /// </summary>
    public class ConnctionException : Exception
    {
        /// <summary>
        /// 异常代码
        /// </summary>
        public int code = 0;

        /// <summary>
        /// 异常消息
        /// </summary>
        public string msg = string.Empty;

        /// <summary>
        /// 异常实例
        /// </summary>
        private Exception innerException;

        /// <summary>
        /// 无参初始化函数
        /// </summary>
        public ConnctionException() { }

        /// <summary>
        /// 带异常代码初始化函数
        /// </summary>
        /// <param name="code">代码</param>
        public ConnctionException(int code) : base()
        {
            this.code = code;
        }

        /// <summary>
        /// 带异常代码、异常消息初始化函数
        /// </summary>
        /// <param name="code">代码</param>
        /// <param name="msg">文本消息</param>
        public ConnctionException(int code, string msg) : base(msg)
        {
            this.code = code;
            this.msg = msg;
        }

        /// <summary>
        /// 带异常代码、异常实例初始化函数
        /// </summary>
        /// <param name="code">代码</param>
        /// <param name="innerException">异常实例</param>
        public ConnctionException(int code, Exception innerException) : base("程序执行中错误.", innerException)
        {
            this.code = code;
            this.innerException = innerException;
        }

        /// <summary>
        /// 带异常代码、异常消息、异常实例初始化函数
        /// </summary>
        /// <param name="code">代码</param>
        /// <param name="msg">错误消息</param>
        /// <param name="innerException">异常实例</param>
        public ConnctionException(int code, string msg, Exception innerException) : base(msg, innerException)
        {
            this.code = code;
            this.msg = msg;
            this.innerException = innerException;
        }

        /// <summary>
        /// 带异常消息初始化函数
        /// </summary>
        /// <param name="msg">异常消息</param>
        public ConnctionException(string msg) : base(msg)
        {
            this.msg = msg;
        }

        /// <summary>
        /// 带异常消息、异常实例初始化函数
        /// </summary>
        /// <param name="msg">错误文本消息</param>
        /// <param name="innerException">错误消息</param>
        public ConnctionException(string msg, Exception innerException) : base(msg, innerException)
        {
            this.msg = msg;
            this.innerException = innerException;
        }

        /// <summary>
        /// 获取异常消息
        /// </summary>
        /// <returns></returns>
        public string GetError()
        {
            return msg;
        }
    }
}